#define _CRT_SECURE_NO_WARNINGS  1
#include <stdio.h>

int main() {
    int n = 0;
    while (scanf("%d", &n) != EOF)
    {
        int arr[1000][2];
        int i = 0;
        int a = 0;
        for (i = 0; i < n; i++)
        {
            scanf("%d%d%d", &a, &arr[i][0], &arr[i][1]);
        }
        int j = 0;
        for (j = 0; j < n - 1; j++)
        {
            for (i = 0; i < n - j - 1; i++)
            {
                if (arr[i][0] > arr[i + 1][0])
                {
                    int temp1 = arr[i][0];
                    int temp2 = arr[i][1];
                    arr[i][0] = arr[i + 1][0];
                    arr[i][1] = arr[i + 1][1];
                    arr[i + 1][0] = temp1;
                    arr[i + 1][1] = temp2;
                }
            }
        }
        int count1[1000] = { 0 };
        for (j = 0; j < n - 1; j++)
        {
            int count = 1;
            int max = arr[j][1];
            for (i = j + 1; i < n; i++)
            {
                if (max <= arr[i][1])
                {
                    count++;
                    max = arr[i][1];
                }
            }
            count1[j] = count;
        }
        int count_max = 0;
        for (i = 0; i < n; i++)
        {
            if (count_max < count1[i])
            {
                count_max = count1[i];
            }
        }
        printf("%d\n", count_max);
    }

    return 0;
}